package com.lq.educationsystem.lqclasses.controller;

import com.lq.educationsystem.common.util.Result;
import com.lq.educationsystem.common.util.ResultBuild;
import com.lq.educationsystem.common.util.ResultPage;
import com.lq.educationsystem.common.vo.ClassesSubjectPageVo;
import com.lq.educationsystem.lqclasses.entiy.ClassesSubjectTb;
import com.lq.educationsystem.lqclasses.service.ClassesSubjectBaseService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Tag(name = "班级课程表")
@RequestMapping("/classes/subject/base")
@RestController
public class ClassesSubjectBaseController {

    @Autowired
    ClassesSubjectBaseService classesSubjectBaseService;

    //增加

    @Operation(summary = "插入班级课程信息")
    @PostMapping("/insert")
    public Result insertInfo(@RequestBody ClassesSubjectTb classesSubjectInfo){

        classesSubjectBaseService.insertInfo(classesSubjectInfo);
        return ResultBuild.buildOk();
    }
    //删除
    @Operation(summary = "删除班级课程通过id")
    @PostMapping("/delete")
    public Result deleteById(@RequestBody ClassesSubjectTb classesSubjectInfo){
        Integer classesSubjectId = classesSubjectInfo.getClassesSubjectId();
        //删除
        classesSubjectBaseService.deleteById(classesSubjectId);
        return ResultBuild.buildOk();

    }
    //更新
    @Operation(summary = "更新班级信息id")
    @PostMapping("/update")
    public Result updateInfo(@RequestBody ClassesSubjectTb classesSubjectInfo){
        classesSubjectBaseService.updateInfo(classesSubjectInfo);
        return ResultBuild.buildOk();
    }
    //通过id查询
    @Operation(summary = "通过班级课程id查询班级信息")
    @PostMapping("/querybyid")
    public Result<ClassesSubjectTb> queryById(@RequestBody ClassesSubjectTb classesSubjectInfo){
        Integer classesSubjectId = classesSubjectInfo.getClassesSubjectId();
        //通过id查询
        Result result =  classesSubjectBaseService.queryById(classesSubjectId);

        return result;
    }

    //查询集合like
    @Operation(summary = "分页查询")
    @PostMapping("/query")
    public ResultPage<ClassesSubjectTb> queryList(@RequestBody ClassesSubjectPageVo classesStudentPageVo){

        ResultPage<ClassesSubjectTb> resultPage=classesSubjectBaseService.queryList(classesStudentPageVo);
        return resultPage;
    }


    //查询班级课程
    @Operation(summary = "通过班级id查询班级课程信息")
    @PostMapping("/query/subject")
    public ResultPage<ClassesSubjectTb> querySubjectInfoListByClassesId(@RequestBody ClassesSubjectPageVo classesSubjectPageVo){
        ResultPage<ClassesSubjectTb> resultPage = classesSubjectBaseService.querySubjectInfoListByClassesId(classesSubjectPageVo);
        return resultPage;
    }
    //通过teacher_subject_id查询信息

    @Operation(summary = "通过教师课程id查询班级课程信息")
    @PostMapping("/query/teacher/subject")
    public ResultPage<ClassesSubjectTb> queryClassesSubjectInfoByTeacherSubjectId(@RequestBody List<Integer> teacherSubjectIdList) {

        ResultPage<ClassesSubjectTb> classesSubjectTbResultPage = classesSubjectBaseService.queryClassesSubjectInfoByTeacherSubjectId(teacherSubjectIdList);
        return classesSubjectTbResultPage;
    }
}
